#ifndef __TYPE_COMMON_H__
#define __TYPE_COMMON_H__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
#include <stdarg.h>
#include <deviceConfig.h>
#if DEVICE_PLATFORM_CONFIGURE == DEVICE_PLATFORM_C51_MCU
typedef char int8_t;
typedef int int16_t;
typedef long int32_t;
typedef unsigned char uint8_t;
typedef unsigned int uint16_t;
typedef unsigned long uint32_t;
#define MCU_CONST_TYPE code
#define MCU_XDATA_TYPE xdata
#else
#include <inttypes.h>
#define MCU_CONST_TYPE
#define MCU_XDATA_TYPE 
#endif

// get struct's member's size
// #define MEMBER_SIZE(type, member) (sizeof(((type *)0)->member))
// get offset of member in struct
// #define MEMBER_OFFSET(type, member) ((int)(&(((type *)0)->member)))
// get master struct's pointer from struct's member
// ptr is member's pointer, type is struct's type, member is member's name
#define container_of(ptr, type, member) ((type *)((char *)(ptr) - (char *)(&((type *)0)->member)))
// get one type array number
#define ARRAY_LEN(a) (sizeof(a) / sizeof(a[0]))
// limit a in [min, max]
#define LIMIT_VAL(a, min, max) ((a) > (max) ? (max) : ((a) < (min) ? (min) : (a)))
// cycle add
#define CYCLE_ADD(a, add, len) (((a) + (add)) % (len))
// swap data
#define SWAP_BASE_VAL(a, b) (a ^= b, b ^= a, a ^= b)
// convert pointer to value
#define ptr_value(vtype, ptr) (*((vtype *)(ptr)))

// platform include
#include <platSysTimeMs.h>
#include <platLogPrintf.h>

// common lib include
#include <crcCalc.h>
#include <typeConvert.h>
#include <genrand.h>
#include <charQueue.h>
// #include <stateMachine.h>
#include <miscOperate.h>

#endif
